#include <iostream>
#include <vector>
#include <stack>

using namespace std;

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> stack;
        int num1, num2;
        for (string token : tokens) {
            if (token.length() == 1) {
                switch (token[0]) {
                    case '+':
                        num2 = stack.top();
                        stack.pop();
                        num1 = stack.top();
                        stack.pop();
                        stack.push(num1 + num2);
                        break;
                    case '-':
                        num2 = stack.top();
                        stack.pop();
                        num1 = stack.top();
                        stack.pop();
                        stack.push(num1 - num2);
                        break;
                    case '*':
                        num2 = stack.top();
                        stack.pop();
                        num1 = stack.top();
                        stack.pop();
                        stack.push(num1 * num2);
                        break;
                    case '/':
                        num2 = stack.top();
                        stack.pop();
                        num1 = stack.top();
                        stack.pop();
                        stack.push(num1 / num2);
                        break;
                    default:
                        stack.push(atoi(token.data()));
                        break;
                }
            } else {
                stack.push(atoi(token.data()));
            }
        }
        return stack.top();
    }
};

int main() {
    Solution solution;
    vector<string> input = {"10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"};
    int output = solution.evalRPN(input);
    cout << output << endl;
    return 0;
}

